// mayaoqing haixiazai

import 'package:flutter/material.dart';
import "package:get/get.dart";
import 'package:osg/controllers/http.dart';


class Invitation extends StatefulWidget {
  const Invitation({super.key});

  @override
  State<Invitation> createState() => _SettingPageState();
}


class _SettingPageState extends State<Invitation> {

RxMap info={}.obs;
RxList list=[].obs;
getInfo(){
  
 Get.find<HTTPS>().getData('/user/invite', {}).then((res){
      if(res!=null){
        info.value = res;
        list.value = res['list'];
      }
    });

}

  @override
  void initState() {
    super.initState();
     WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
    });
  }

  @override
  Widget build(BuildContext context) {
    final totalHeight = MediaQuery.of(context).padding.top+15;
    return Scaffold(
      backgroundColor: Color(0XFF040E24),
        body: ListView(
      children: [
        Stack(
          children: [
            Container(
              margin: EdgeInsets.only(top: totalHeight),
              child: Image.asset(
                'static/images/inctonhimg.png',
                fit: BoxFit.fitWidth,
              ),
            ),
            Positioned(
              left: 8.0,
              top: 20,
              child: IconButton(
                onPressed: () {
                  Get.back();
                  print('object');
                },
                icon: Image.asset(
                  'static/images/bback.png',
                  width: 22,
                  fit: BoxFit.fitWidth,
                ),
              ),
            ),
            Positioned(
              left: 70,
              right:70,
              bottom: 25,
              child: 
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                Container(
                  child: Column(
                    children: [
                      Image.asset('static/web/mayaoqing.png',width: 40,fit: BoxFit.fitWidth,),
                      SizedBox(height: 5,),
                      Text('复制邀请码',style: TextStyle(fontSize: 12,color: Color(0XFF333333))),
                    ],
                  ),
                ),
                Container(
                  child: Column(
                    children: [
                      Image.asset('static/web/haixiazai.png',width: 40,fit: BoxFit.fitWidth,),
                      SizedBox(height: 5,),
                      Text('下载邀请海报',style: TextStyle(fontSize: 12,color: Color(0XFF333333))),
                    ],
                  ),
                ),
              ],)

            ),
          ],
        ),
        Align(
          alignment: Alignment.center, // 水平&垂直居中
          child: Text(
            '保存海报或复制邀请码分享好友获得奖励',
            style: TextStyle(fontSize: 12, color: Color(0xff999999)),
          ),
        ),
        Align(
          alignment: Alignment.center,
          child: Container(
            width: 150,
            height: 40,
            margin: EdgeInsets.only(top: 30, bottom: 30),
            decoration: BoxDecoration(
                color: Color(0xff333333),
                borderRadius: BorderRadius.circular(50)),
            child: TextButton(
              style: ButtonStyle(
                textStyle: WidgetStateProperty.all(TextStyle(fontSize: 16)),
                backgroundColor: WidgetStateProperty.all(Color(0xff333333)),
              ),
              onPressed: () {
                Get.toNamed('/poster?qr=${info['qr']}');
                // 触发点击逻辑 :ml-citation{ref="1,3" data="citationList"}
              },
              child: Text(
                '立即邀请',
                style: TextStyle(color: Color(0xffffffff)),
              ),
            ),
          ), // 左侧对齐且宽度生效
        ),
        Container(
          padding: EdgeInsets.symmetric(vertical: 10),
          decoration: BoxDecoration(
              border: Border(
            top: BorderSide(color: Color(0xffdddddd)),
            bottom: BorderSide(color: Color(0xffdddddd)),
          )),
          child: Image.asset('static/images/gonglie.png'),
        ),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: 15),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              SizedBox(height: 20),
              Row(
                children: [
                  Text(
                    '我的邀请',
                    style: TextStyle(fontSize: 20),
                  ),
                  Image.asset(
                    'static/images/gantan.png',
                    width: 13,
                    fit: BoxFit.fitWidth,
                  ),
                  Text(
                    '规则说明',
                    style: TextStyle(fontSize: 12, color: Color(0xff333333)),
                  ),
                ],
              ),
              Row(
                children: [
                  Text(
                    '已邀请',
                    style: TextStyle(fontSize: 12, color: Color(0xff999999)),
                  ),
                  Obx(()=>
                    Text(
                      '${info['invite_num']}',
                      style: TextStyle(fontSize: 12),
                    )
                  )
                  ,
                  Obx(()=>
                  Text(
                    '人，有效邀请${info['invite_idcard']}人，共获得',
                    style: TextStyle(fontSize: 12, color: Color(0xff999999)),
                  )
                  )
                  ,
                  Text(
                    '0星币',
                    style: TextStyle(fontSize: 12),
                  ),
                  Text(
                    '奖励',
                    style: TextStyle(fontSize: 12, color: Color(0xff999999)),
                  ),
                ],
              ),

              SizedBox(height: 20), // 添加间距
              Obx(()=>
              Column(
                children: [
              for(var item in list.asMap().entries)
              Container(
                margin: EdgeInsets.only(bottom: 20),
                child:  Row(
                children: [
                  CircleAvatar(
                    radius: 22,
                    child: Image.network(
                      '${item.value['headimg']}'
                    ),
                  ),
                  SizedBox(width: 10), // 添加间距
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '${item.value['name']}',
                          style: TextStyle(
                              fontSize: 15, fontWeight: FontWeight.bold),
                        ),
                        SizedBox(height: 2), // 添加间距
                        Text(
                          '${item.value['created_at']}',
                          style: TextStyle(
                            color: Colors.grey,
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ),
                  ),
                  SizedBox(width: 10), // 添加间距
                  Text(
                    '${item.value['idcard']}',
                    style: TextStyle(
                      color: Color(0xff999999),
                      fontSize: 12,
                    ),
                  ),
                ],
              ),
              )
                ],
              )
                 
             
              )
             
             
              // SizedBox(height: 20), // 添加间距
              // Row(
              //   children: [
              //     CircleAvatar(
              //       radius: 22,
              //       backgroundImage:
              //           AssetImage('static/aaa.png'), // 替换为你的静态图片路径
              //     ),
              //     SizedBox(width: 10), // 添加间距
              //     Expanded(
              //       child: Column(
              //         crossAxisAlignment: CrossAxisAlignment.start,
              //         children: [
              //           Text(
              //             '啊呜严选啊呜严选',
              //             style: TextStyle(
              //                 fontSize: 15, fontWeight: FontWeight.bold),
              //           ),
              //           SizedBox(height: 2), // 添加间距
              //           Text(
              //             '2020.04.08 12:22',
              //             style: TextStyle(
              //               color: Colors.grey,
              //               fontSize: 12,
              //             ),
              //           ),
              //         ],
              //       ),
              //     ),
              //     SizedBox(width: 10), // 添加间距
              //     Text(
              //       '等待实名认证',
              //       style: TextStyle(
              //         color: Color(0xff999999),
              //         fontSize: 12,
              //       ),
              //     ),
              //   ],
              // ),
            
            ],
          ),
        )
      ],
    ));
  }
}
